package SV_SOCKETS;

public class Example {
    public class SV_SOCKETS_Sample_1 extends Applet {
        static final int PORT = 7776;
        public void init() {
            super.init();
            try {
                final ServerSocket serv = new ServerSocket(PORT);
                Runnable rr = new Runnable() {
                    public void run() {
                        try {
                            while (true) {
                                Socket sock = serv.accept();
                                BufferedReader r = new BufferedReader(
                                        new InputStreamReader(sock
                                                .getInputStream()));
                                PrintWriter w = new PrintWriter(sock
                                        .getOutputStream(), false); // no autoFlush
                                w.write("Hello");
                                w.flush();
                                r.close();
                                w.close();
                                sock.close();
                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                };
                new Thread(rr).start();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
        //...
        public void paint(Graphics g) {
        }
    }
}
